﻿using SOMAWP7;

namespace Starter3DGame
{
    public class AdvertisingFramework
    {
        static AdvertisingFramework instance;
        SomaAd somaAd = new SomaAd();

        private AdvertisingFramework()
        {
            somaAd.Adspace = 12345678;
            somaAd.Pub = 12345678;
            somaAd.AdInterval = 10000;
            somaAd.GetAd();
        }

        public static AdvertisingFramework Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new AdvertisingFramework();
                }

                return instance;
            }
        }

        public static void Dispose()
        {
            instance.somaAd.Dispose();
            instance = null;
        }




        /*
        somaAd.NewAdAvailable += new SomaAd.OnNewAdAvailable(somaAd_NewAdAvailable);
         
         void somaAd_NewAdAvailable(object sender, EventArgs e)
            {
              if (somaAd.Status == "error")
              {
                textBoxErrorCode.Text = somaAd.ErrorCode;
                textBoxErrorDescription.Text = DateTime.Now.ToShortTimeString() + " " +
                                               somaAd.ErrorDescription;
              }
              else
              {
                if (somaAd.AdText != String.Empty)
                  textBoxTextAd.Text = somaAd.adText;        
                if (somaAd.AdType == "IMG")
                {
                  ++adCounter;
                  textBoxAdCounter.Text = adCounter.ToString();
                  textBoxGifCounter.Text = somaAd.GifImageCount.ToString();
                  textBoxImageType.Text = somaAd.ContentType;
          
                  int pixelHeight = somaAd.AdImage.PixelHeight;
                  int pixelWidth = somaAd.AdImage.PixelWidth;

                  webBrowserAdImage.Source = new Uri(somaAd.AdImageUri);
                }
              }
            }

         WebBrowserTask wb = new WebBrowserTask();;
        private void imageAd_MouseEnter(object sender, MouseEventArgs e)
        {
            if (somaAd.Uri != "" && somaAd.Uri != string.Empty)
            {
                wb.Uri = new Uri(somaAd.Uri);
                wb.Show();
            }
        }         
         */

    }
}
